package com.dubbo.cp.uitls;

import java.util.ArrayList;
import java.util.List;

public class Pager<T> {

	private int currentPage = 1;//当前页
	private int recordSize = 3;//显示记录
	private boolean hasPrevious = false;//是否有上一页
	private boolean hasNext = false;//是否存在下一页
	private boolean hasLast = false;//是否有最后一页
	List<T> list = new ArrayList<T>();//查出的数据列表
	private int totalPages;//总页数
	
	
	public int getCurrentPage() {
		return currentPage;
	}
	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}
	public int getRecordSize() {
		return recordSize;
	}
	public void setRecordSize(int recordSize) {
		this.recordSize = recordSize;
	}
	
	public boolean isHasPrevious() {
		if(currentPage>1)
		{
			return true;
		}
		return hasPrevious;
	}

	public boolean isHasNext() {
		if(currentPage<totalPages)
		{
			return true;
		}
		return hasNext;
	}
	
	public boolean isHasLast() {
		if(currentPage!=totalPages)
		{
		   return true;
		}
		return hasLast;
	}
	
	public List<T> getList() {
		return list;
	}
	public void setList(List<T> list) {
		this.list = list;
	}
	/*
	 * 初始化总页数
	 */
	public void initTotalPage( )
	{
		int totalPage=list.size()/recordSize;
		this.totalPages=(list.size()/recordSize==0)?totalPage:totalPage+1;
	}
	public int getTotalPages() {
		return totalPages;
	}
	public void setTotalPages(int totalPages) {
		this.totalPages = totalPages;
	}
	
	
}
